home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / hf^k-6.dms / in.adf / Install.run / GOLDEDDATA / developer / examples / scanner / source / autodocslow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-31  |  2.2 KB  |  93 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   COPYIGHT
  4.  
  5.   ©1995  Dietmar  Eilert  (e-mail:  DIETMAR@TOMATE.TNG.OCHE.DE).  All  Rights
  6.   Reserved.  Code  may not be reused/reproduced without written permission of
  7.   the author.
  8.  
  9.   Dietmar Eilert
  10.   Mies-v-d-Rohe-Str.31, 52074 Aachen, Germany
  11.   E-Mail: DIETMAR@TOMATE.TNG.OCHE.DE
  12.   Tel: +49-(0)241-81665
  13.        +49-(0)2525-7776
  14.   Fax: +49-(0)241-81665
  15.  
  16.   Example: scan handler looking for  AutoDoc  nodes.  Scan  handlers  are  plain
  17.   functions  (LoadSeg'ed  by GED): no standard C startup code, no library calls.
  18.   This handler is faster than GoldED's built in AutoDoc handler since it  simply
  19.   looks  for formfeeds. Won't work with all AutoDocs though Commodore's AutoDocs
  20.   are handled properly.
  21.   
  22.   DICE C:
  23.  
  24.   dcc autodocslow.c -// -l0 -md -mRR -o ram:autodocslow
  25.  
  26.   ------------------------------------------------------------------------------
  27. */
  28.  
  29. #include <exec/types.h>
  30.  
  31. #define FORMFEED 12
  32.  
  33. ULONG
  34. ScanHandlerGuide(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  35. {
  36.     const char *version = "$VER: ADocSlow 1.0 (" __COMMODORE_DATE__ ")";
  37.  
  38.     ULONG length;
  39.  
  40.     // look for node header; example: assert/abort  assert/abort
  41.  
  42.     for (length = len; length; --length) {
  43.  
  44.         if (**text == '/') {
  45.  
  46.             UWORD  keyLen;
  47.             UBYTE *next;
  48.  
  49.             // get description length (leading "/" included).
  50.  
  51.             for (next = *text, keyLen = 0; length && (*next != ' '); --length, ++next)
  52.  
  53.                 ++keyLen;
  54.  
  55.             if (keyLen) {
  56.  
  57.                 // search for repeated node header
  58.  
  59.                 while (length) {
  60.  
  61.                     if (*next == '/') {
  62.  
  63.                         UWORD compare;
  64.  
  65.                         // same node header ?
  66.  
  67.                         for (compare = 0; compare < keyLen; ++compare)
  68.  
  69.                             if (next[compare] != (*text)[compare])
  70.  
  71.                                 return(FALSE);
  72.  
  73.                         // remove leading "/"
  74.  
  75.                         ++*text;
  76.  
  77.                         return(keyLen - 1);
  78.                     }
  79.  
  80.                     --length;
  81.                     ++next;
  82.                 }
  83.             }
  84.  
  85.             break;
  86.         }
  87.         else
  88.             ++*text;
  89.     }
  90.  
  91.     return(FALSE);
  92. }
  93.